<?php


namespace app\common\model;

use think\Model;

/**
 * 基础模型
 * @package app\common\model
 */
class AdminBaseModel extends Model
{
    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    /**
     * 获取label和value的list
     * @param string $labelField
     * @param mixed $valueFiled
     * @param array $where
     * @return array
     */
    public static function getListOnLabelValue(string $labelField = '', $valueFiled = '', array $where = [])
    {
        $filed = $labelField . ' as label,' . $valueFiled . ' as value';
        return static::where($where)->column($filed);
    }

    public static function getMappingList(string $labelField = '', $valueFiled = '', array $where = [])
    {
        $fastlist = ['*' => '-'];
        $list = static::where($where)->column($labelField, $valueFiled);
        return array_merge($fastlist, $list);
    }
}
